﻿using System;
using Combat;
using PrimeTween;
using UI;
using UnityEngine;

namespace Visual
{
    public class WeaponSwitchVisual : MonoBehaviour
    {
        [SerializeField] private UiFader newWeaponText;
        [SerializeField] private ParticleSystem switchEffect;
        
        private WeaponSwitch _weaponSwitch;


        private void Awake()
        {
            _weaponSwitch = GetComponent<WeaponSwitch>();
            
            _weaponSwitch.WeaponUnlocked += WeaponSwitch_WeaponUnlocked;
            _weaponSwitch.WeaponSwitched += WeaponSwitch_WeaponSwitched;
        }

        private void WeaponSwitch_WeaponSwitched(int index, Weapon _)
        {
            switchEffect.Play();
        }

        private void WeaponSwitch_WeaponUnlocked(int index, Weapon _)
        {
            newWeaponText.Show();
            Tween.Delay(2f, newWeaponText.Hide);
        }
    }
}